# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Jens Pranaitis <jens@jenux.homelinux.org>

pkgname=busybox
pkgver=1.36.1
pkgrel=1
pkgdesc="Utilities for rescue and embedded systems"
arch=("loong64" "x86_64")
url="https://www.busybox.net"
license=('GPL')
makedepends=("ncurses" "musl" "kernel-headers-musl")
validpgpkeys=('C9E9416F76E610DBD09D040F47B70C55ACC9965B')
source=("$url/downloads/$pkgname-$pkgver.tar.bz2"{,.sig}
        "config")
sha256sums=('b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314'
            'SKIP'
            '239001693b58e471c594952b9805c24b0d8174ba2cab245cd624e4423d993cd3')
b2sums=('e515825cb3ab1c520e16b9c2512e9fc72947366a72a0466bff59b507fdffbc78fc9d16b44a26116175fc7a429d849ad944b1bc379d36c6d3a0eb20969997336e'
        'SKIP'
        '7d4759036db05d7e0c06571e8fd24db488edf87a9b82a5382eee3fb43fc5318bbd75398e43c9b30c88b78630e910ee9a5316aaa824b5ab26f93fc1b3f834f07d')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  cp "$srcdir"/config .config
  # reproducible build
  export KCONFIG_NOTIMESTAMP=1
  make CC=musl-gcc
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -Dm0755 busybox "$pkgdir"/usr/bin/busybox

  # docs
  install -Dm644 docs/busybox.1 "$pkgdir"/usr/share/man/man1/busybox.1
  for doc in BusyBox.html BusyBox.txt; do
    install -Dm644 docs/$doc "$pkgdir"/usr/share/doc/$pkgname/$doc
  done
}
